﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 剧情设计器2._0
{
    public partial class RelationshipTable : Form
    {
        public RelationshipTable()
        {
            InitializeComponent();
        }

        void UpdateDisplay()
        {
            comboBox_character.BeginUpdate();
            comboBox_character.Items.Clear();
            foreach(Character c in Common.characters)
            {
                comboBox_character.Items.Add(c.name);
            }
            comboBox_character.EndUpdate();

            comboBox_relationship.BeginUpdate();
            comboBox_relationship.Items.Clear();
            foreach (string type in Common.relationship_types)
            {
                comboBox_relationship.Items.Add(type);
            }
            comboBox_relationship.EndUpdate();
        }

        private void btn_search_Click(object sender, EventArgs e)
        {
            listBox_result.Items.Clear();
            listBox_result.BeginUpdate();
            foreach(Character c in Common.characters)
            {
                string name = c.name;
                try
                {
                    if (Common.inList(comboBox_relationship.Text, Common.relationshipTable[comboBox_character.Text][name]))
                    {
                        listBox_result.Items.Add(name);
                    }
                }
                catch
                {

                }
            }
            listBox_result.EndUpdate();
        }

        private void RelationshipTable_Load(object sender, EventArgs e)
        {
            UpdateDisplay();
        }
    }
}
